package exception;

import java.util.Scanner;

class Account {
	int accNo;
	String name;
	float amount;

	void createAccount(int i, String s, float f) {
		accNo = i;
		name = s;
		amount = f;
	}

	void display() {
		System.out.println("AccountNo: " + accNo);
		System.out.println("Name: " + name);
		System.out.println("Amount: " + amount);
	}
}

@SuppressWarnings("serial")
class MyException extends Exception {
	MyException() {
	}

	MyException(String str) {
		super(str);
	}
}

class TestClass {
	public static void main(String args[]) {
		Scanner obj = new Scanner(System.in);
		Account myAcc = new Account();
		System.out.print("Enter AccNo:");
		int acNo = obj.nextInt();
		System.out.print("Enter Name:");
		String name = obj.next();
		float amount;
		while (true) {
			try {
				System.out.print("Enter Amount:");
				amount = obj.nextFloat();
				if (amount >= 500) {
					myAcc.createAccount(acNo, name, amount);
					myAcc.display();
					break;
				} else
					throw new MyException(
							"Account cant be created, Minimum Amount is 500");
			} catch (MyException e) {
				System.out.println(e.toString());
			}
		}
	}
}
